package com.gupao.gupaoeduvippattern.javaBase.test;

import org.junit.jupiter.api.Test;

import java.lang.management.ManagementFactory;

public class Demo1 {


    @Test
    public void test3(){
        int a = 1;
        double d = 1.0;
        if(a == d){
            System.out.println("相等");
        }else{
            System.out.println("不相等");
        }


        /*for(int i=0; i<Character.MAX_VALUE; i++){
            if(i%100 == 0){
                System.out.println();
            }
            System.out.print((char)i+",");
        }*/
    }


    @Test
    public void test2(){
        String cardID = "429004199206171773";
        System.out.println(verifyCardID(cardID));
    }

    public String verifyCardID(String cardID){
        if(cardID==null || "".equals(cardID)){
            return "身份证信息不可为空";
        }
        /*if(cardID.length() != 18){
            return "身份证卡号不是18位";
        }*/

        int[] array = new int[18];
        for(int i=0; i<cardID.length(); i++){
            array[i] = Integer.valueOf(cardID.substring(i, i+1));
//            char c = cardID.charAt(i);
//            System.out.println(c);
        }
        int sum = 0;
        for(int i=0; i<array.length-1; i++){
            double a = array[i] * Math.pow(2, (17-i));
            sum += array[i] * Math.pow(2, (17-i));
            System.out.print(i+","+sum+"@");
        }
        System.out.println();
        int checkNode = (12-(sum % 11))%11;
        System.out.println("身份证最后一位校验码为：" + checkNode);
        if(checkNode == array[array.length-1]){
            return "正确的身份证ID";
        }

        return "错误的身份证ID";
    }


    @Test
    public void test1(){
        run();
        eat();
        System.out.println("结束。。。。");

    }

    public void run(){
        System.out.println("person is run!");
        return;
    }

    public void eat(){
        System.out.println("person is eat");
    }


}
